package controler;

import java.util.Observable;

import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;

import javax.swing.JTabbedPane;

import template.AbstractListener;

import model.Delivery;

public class ChangeRestaurantListener extends AbstractListener implements ChangeListener{
	
	private static final long serialVersionUID = 1L;
	
	public ChangeRestaurantListener(Observable obs){
		addModel(obs);
	}
	
	public void stateChanged(ChangeEvent evt){
		JTabbedPane source = (JTabbedPane)evt.getSource();
		Delivery delivery = (Delivery)getModel(0);
		
		String title = source.getTitleAt(source.getSelectedIndex());
		delivery.setRestaurantName(title);
	}
}
